﻿<%@ Page Language="C#" AutoEventWireup="false" Inherits="Bee.Web.BeePageView" %>

<%@ Import Namespace="Bee.Web" %>
<%@ Import Namespace="Bee" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%
    int id = ViewData.TryGetValue<int>("id", 0);
    int userId = ViewData.TryGetValue<int>("userid", 0);
%>
<div class="pageContent">
    <form method="post" action="<%=HtmlHelper.ForActionLink("save") %>" class="required-validate alertMsg noRefresh"
    id="content<%=PageId %>">
    <%=HtmlHelper.ForHidden("createtime") %>
    <%=HtmlHelper.ForHidden("userid") %>
    <div class="topFormBar">
        <ul>
            <li><a class="button" href="javascript:" onclick="javascript:autoSave('content<%=PageId %>');">
                <span>保存</span> </a></li>
            <li><a class="button close" href="javascript:"><span>取消</span> </a></li>
            <%if (id > 0 && userId == 0)
              { %>
            <li style="margin-left: 20px;"><a class="button" href='/AuthUser/Show.bee?id=-1&eid=<%=ViewData["id"] %>'
                target="dialog" width="800" height="480" title="创建" mask="true"><span>开通系统账号</span>
            </a></li>
            <%} %>
        </ul>
    </div>
    <div class="pageFormContent" layouth="56">
        <div class="tabs" currentindex="0" eventtype="click">
            <div class="tabsHeader">
                <div class="tabsHeaderContent">
                    <ul>
                        <li><a href="javascript:;"><span>基本信息</span></a></li>
                        <li><a href="javascript:;"><span>座位信息</span></a></li>
                    </ul>
                </div>
            </div>
            <div class="tabsContent">
                <div>
                    <dl>
                        <dt>Id：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("id", "readonly=readonly") %></dd>
                    </dl>
                    <dl>
                        <dt>姓名：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("Truename", "class=required") %></dd>
                    </dl>
                    <dl>
                        <dt>工号：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("WorkCode", "class=required") %></dd>
                    </dl>
                    <dl>
                        <dt>部门：</dt>
                        <dd class="unitBox">
                            <%=HtmlHelper.ForHidden("departmentid", "id=id") %>
                            <input name="departmentname" id="name" type='text' lookupgroup="" value='<%=HtmlHelper.ForDataMapping("OrganizationMapping", "departmentid") %>'
                                autocomplete="off" suggesturl="/Organization/Suggest.bee?ct=2" suggestfields="name"
                                postfield="name" style='display: block; float: left;' class="" /></dd>
                    </dl>
                    <dl>
                        <dt>性别：</dt>
                        <dd>
                            <%=HtmlHelper.ForSelect("sex", "sexinfo", false)  %></dd>
                    </dl>
                    <dl>
                        <dt>生日：</dt>
                        <dd>
                            <%=HtmlHelper.ForDatetimeTextBox("birthday", "yyyy-MM-dd", "class=date", "minDate=1950-1-2")%></dd>
                    </dl>
                    <dl>
                        <dt>民族：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("nation")  %></dd>
                    </dl>
                    <dl>
                        <dt>政治面貌：</dt>
                        <dd>
                            <%=HtmlHelper.ForSelect("partyid", "partyinfo", false)  %></dd>
                    </dl>
                    <dl>
                        <dt>文化程度：</dt>
                        <dd>
                            <%=HtmlHelper.ForSelect("educationid", "educationinfo", false)  %></dd>
                    </dl>
                    <dl>
                        <dt>籍贯：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("jiguan")  %></dd>
                    </dl>
                    <dl>
                        <dt>婚姻状况：</dt>
                        <dd>
                            <%=HtmlHelper.ForSelect("Marryid", "marriageinfo", false)  %></dd>
                    </dl>
                    <dl>
                        <dt>健康状况：</dt>
                        <dd>
                            <%=HtmlHelper.ForSelect("healthid", "healthinfo", false)  %></dd>
                    </dl>
                    <dl>
                        <dt>身份证号：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("shenfenid")  %></dd>
                    </dl>
                    <dl class="nowrap">
                        <dt>联系电话：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("phone")  %></dd>
                    </dl>
                    <dl class="nowrap">
                        <dt>Email：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("email")  %></dd>
                    </dl>
                    <dl>
                        <dt>家庭地址：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("address", "size=100")%></dd>
                    </dl>
                    <dl class="nowrap">
                        <dt>现居住地址：</dt>
                        <dd>
                            <%=HtmlHelper.ForTextBox("abode", "size=100")%></dd>
                    </dl>
                    <dl>
                        <dt>个人简介：</dt>
                        <dd>
                            <textarea name="remark" cols="60" rows="5"><%=ViewData["remark"] %></textarea></dd>
                    </dl>
                </div>
                <div>
                    <%=HtmlHelper.ForSelect("opid", "OfficePosition", false) %>
                    <%=HtmlHelper.ForHidden("epinfo")%>
                    <div id="holder<%=PageId %>">
                        <img id="img<%=PageId %>" />
                    </div>
                </div>
            </div>
        </div>
    </div>
    </form>
</div>

<script language="javascript">

    var dragItem = null;
    var moveFlag = false;
    var lastX, lastY;

    var paper = null;
    var timerInterval = null;
    var main = function() {
        var tagImage = $("#img<%=PageId %>");
        var width = tagImage.width();
        var height = tagImage.height();
        if (timerInterval) {
            timerInterval = clearInterval(timerInterval);
        }
        else {
            return;
        }

        paper = Raphael("holder<%=PageId %>", width + 100, height);

        tagImage.hide();
        var image = paper.image(tagImage.attr("src"), 0, 0, width, height);

        image.mousemove(function(e) {

            if (moveFlag) {
                dragItem.translate(e.layerX - lastX, e.layerY - lastY);
                lastX = e.layerX;
                lastY = e.layerY;
            }

        }).mouseup(function() {
            moveFlag = false;
        });

        showPosition("胡凯烽", "", 200, 100);
        showPosition("王光英", "", 300, 100);
        showPosition("周游", "", 400, 100);
        showPosition("罗燕青", "", 500, 100);
    }

    var showPosition = function(name, mark, x, y) {


        var people = paper.set();
        people.push(paper.circle(0, 15, 10).attr({ fill: "#0f0" }));
        people.push(paper.text(0, 0, name));
        people.translate(x, y);

        people.dblclick(function(e) {
            debugger;
        });

        people.mousedown(function(e) {
            moveFlag = true;
            dragItem = people;
            lastX = e.layerX;
            lastY = e.layerY;
        }).mouseup(function() {
            moveFlag = false;
        });


    }


    $(function() {


        timerInterval = setInterval("main()", 500);


        $("#content<%=PageId %>").find("[name=opid]").change(function() {

            bee.PostData("/OfficePosition/Detail.bee", { id: $(this).val() }, function(data) {
                debugger;
                $("#img<%=PageId %>").attr("src", data.imageurl);
            });
        });
    });
    
</script>

